import type { VxeGridProps } from '@vben/plugins/vxe-table';

import type { VbenFormProps } from '#/adapter/form';

import { $t } from '@vben/locales';

// 表格参数定义
export const gridSchemas: VxeGridProps<any> = {
  toolbarConfig: {
    slots: {
      buttons: 'toolbar-buttons',
    },
  },
  checkboxConfig: {
    range: false,
  },
  columns: [
    { type: 'checkbox', width: 50 },
    { title: $t('common.seq'), type: 'seq', width: 50 },
    {
      field: 'docTitle',
      title: $t('devOperation.sop.sopDocInfo.docTitle'),
      treeNode: true,
      align: 'left',
    },
    {
      field: 'docName',
      title: $t('devOperation.sop.sopDocInfo.docName'),
    },
    {
      field: 'docVersion',
      width: 80,
      title: $t('devOperation.sop.sopDocInfo.docVersion'),
    },
    {
      field: 'description',
      title: $t('devOperation.sop.sopDocInfo.description'),
    },
    {
      field: 'isPublish',
      width: 100,
      title: $t('devOperation.sop.sopDocInfo.isPublish'),
      formatter: ({ row }) => {
        if (row.isFolder) {
          return '';
        }
        return row.isPublish ? '已发布' : '未发布';
      },
    },
    {
      field: 'createdTime',
      formatter: 'formatDateTime',
      width: 180,
      title: $t('common.createdTime'),
    },
    {
      field: 'action',
      fixed: 'right',
      title: '操作',
      slots: { default: 'ACTION' },
      width: 150,
    },
  ],
};
// 搜索表单参数定义
export const searchFormSchemas: VbenFormProps = {
  schema: [
    {
      component: 'Input',
      fieldName: 'docAppId',
      label: $t('devOperation.sop.sopDocInfo.docTitle'),
      dependencies: {
        show: false,
        triggerFields: ['docAppId'],
      },
      componentProps: {
        placeholder: '请输入',
        allowClear: true,
      },
    },
    {
      component: 'Input',
      fieldName: 'keyword',
      label: '搜索',
      componentProps: {
        placeholder: '支持接口标题,接口名称',
        allowClear: true,
      },
    },
  ],
};
